
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 01/04/2013 16:32:32
-- Generated from EDMX file: D:\losezhang\Async_await\Async_await\Entity\Model1.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [test];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------


-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Product]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Product];
GO
IF OBJECT_ID(N'[dbo].[Product_Comment]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Product_Comment];
GO
IF OBJECT_ID(N'[dbo].[Review]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Review];
GO
IF OBJECT_ID(N'[dbo].[sysdiagrams]', 'U') IS NOT NULL
    DROP TABLE [dbo].[sysdiagrams];
GO
IF OBJECT_ID(N'[dbo].[User]', 'U') IS NOT NULL
    DROP TABLE [dbo].[User];
GO
IF OBJECT_ID(N'[dbo].[User_Login_Logs]', 'U') IS NOT NULL
    DROP TABLE [dbo].[User_Login_Logs];
GO
IF OBJECT_ID(N'[dbo].[User_Profile]', 'U') IS NOT NULL
    DROP TABLE [dbo].[User_Profile];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'Product'
CREATE TABLE [dbo].[Product] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [UserID] int  NOT NULL,
    [Name] varchar(50)  NULL,
    [Price] decimal(18,0)  NOT NULL,
    [Info] varchar(500)  NULL,
    [Status] int  NOT NULL
);
GO

-- Creating table 'Product_Comment'
CREATE TABLE [dbo].[Product_Comment] (
    [ID] bigint IDENTITY(1,1) NOT NULL,
    [ProductID] int  NOT NULL,
    [UserID] int  NOT NULL,
    [CommentTitle] nvarchar(128)  NOT NULL,
    [CommentInfo] nvarchar(max)  NULL
);
GO

-- Creating table 'Review'
CREATE TABLE [dbo].[Review] (
    [ReviewID] int IDENTITY(1,1) NOT NULL,
    [Info] nvarchar(512)  NULL,
    [CreateDate] datetime  NOT NULL,
    [Status] int  NOT NULL,
    [UserID] int  NOT NULL,
    [ObjID] int  NOT NULL,
    [ObjType] int  NOT NULL
);
GO

-- Creating table 'sysdiagrams'
CREATE TABLE [dbo].[sysdiagrams] (
    [name] nvarchar(128)  NOT NULL,
    [principal_id] int  NOT NULL,
    [diagram_id] int IDENTITY(1,1) NOT NULL,
    [version] int  NULL,
    [definition] varbinary(max)  NULL
);
GO

-- Creating table 'User'
CREATE TABLE [dbo].[User] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Name] varchar(50)  NULL,
    [Status] int  NOT NULL,
    [Password] varchar(50)  NULL
);
GO

-- Creating table 'User_Login_Logs'
CREATE TABLE [dbo].[User_Login_Logs] (
    [ID] varchar(36)  NOT NULL,
    [UserID] int  NULL,
    [LogTime] datetime  NOT NULL,
    [UserName] varchar(50)  NULL
);
GO

-- Creating table 'User_Profile'
CREATE TABLE [dbo].[User_Profile] (
    [ID] int  NOT NULL,
    [RealName] varchar(50)  NULL,
    [Info] varchar(500)  NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [ID] in table 'Product'
ALTER TABLE [dbo].[Product]
ADD CONSTRAINT [PK_Product]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'Product_Comment'
ALTER TABLE [dbo].[Product_Comment]
ADD CONSTRAINT [PK_Product_Comment]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ReviewID] in table 'Review'
ALTER TABLE [dbo].[Review]
ADD CONSTRAINT [PK_Review]
    PRIMARY KEY CLUSTERED ([ReviewID] ASC);
GO

-- Creating primary key on [diagram_id] in table 'sysdiagrams'
ALTER TABLE [dbo].[sysdiagrams]
ADD CONSTRAINT [PK_sysdiagrams]
    PRIMARY KEY CLUSTERED ([diagram_id] ASC);
GO

-- Creating primary key on [ID] in table 'User'
ALTER TABLE [dbo].[User]
ADD CONSTRAINT [PK_User]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'User_Login_Logs'
ALTER TABLE [dbo].[User_Login_Logs]
ADD CONSTRAINT [PK_User_Login_Logs]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'User_Profile'
ALTER TABLE [dbo].[User_Profile]
ADD CONSTRAINT [PK_User_Profile]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------